package com.bjfu.demo.utils;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;

import java.util.Date;

public class MyTimeUtils {
    public static Date getLastYearBeginDate() {
        DateTime date = DateUtil.date();
        int year = DateUtil.year(date);
        year -= 1;
        return new DateTime(String.valueOf(year) + "-01-01 00:00:00", DatePattern.NORM_DATETIME_FORMAT);
    }

    public static Date getLastYearEndDate() {
        DateTime date = DateUtil.date();
        int year = DateUtil.year(date);
        return new DateTime(String.valueOf(year) + "-01-01 00:00:00", DatePattern.NORM_DATETIME_FORMAT);
    }

    public static Date getLastSeasonBeginDate() {
        DateTime date = DateUtil.date();
        DateTime dateTime = DateUtil.offsetMonth(date, -3);
        return DateUtil.beginOfQuarter(dateTime);
    }

    public static Date getLastSeasonEndDate() {
        DateTime date = DateUtil.date();
        return DateUtil.beginOfQuarter(date);
    }

    public static Date getLastMonthBeginDate() {
        DateTime date = DateUtil.date();
        DateTime dateTime = DateUtil.offsetMonth(date, -1);
        return DateUtil.beginOfMonth(dateTime);
    }

    public static Date getLastMonthEndDate() {
        DateTime date = DateUtil.date();
        return DateUtil.beginOfMonth(date);
    }
}
